package com.example.designpatterns.memento;

public class Client {

    public static void main(String[] args) {
        //记录着
        Originator originator = new Originator();
        //管理者
        Caretaker caretaker = new Caretaker();
        // 设置初始状态
        originator.setState("草稿");
        System.out.println("初始状态: " + originator.getState());

        // 保存状态
        caretaker.setMemento(originator.createMemento());

        // 修改状态
        originator.setState("执行");
        System.out.println("修改后的状态: " + originator.getState());

        // 恢复状态
        originator.restoreMemento(caretaker.getMemento());
        System.out.println("恢复后的状态: " + originator.getState());
    }
}

